package test.shadow;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.le.BluetoothLeScanner;

import org.robolectric.annotation.Implements;
import org.robolectric.annotation.Resetter;
import org.robolectric.shadow.api.Shadow;
import org.robolectric.shadows.ShadowBluetoothAdapter;

import test.util.Log;

@Implements(BluetoothAdapter.class)
public class MyShadowBluetoothAdapter extends ShadowBluetoothAdapter {
    private static final String TAG = MyShadowBluetoothAdapter.class.getSimpleName();

    private static boolean scannerEnabled = true;

    public static void setScannerEnabled(boolean enabled) {
        scannerEnabled = enabled;
    }

    @Resetter
    public static void resetMe() {
        Log.d(TAG, "resetMe");
        scannerEnabled = true;
    }

    public BluetoothLeScanner getBluetoothLeScanner() {
        return (scannerEnabled ? Shadow.newInstanceOf(BluetoothLeScanner.class) : null);
    }
}
